package kr.jin.zeroprojectone;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

public class FragmentDialogDeleteList extends DialogFragment {
	private AlertDialog.Builder dialog;
	private LayoutInflater layoutinflater;
	int position;
	int num;
	
	public static FragmentDialogDeleteList newInstance(int num, int position){
		FragmentDialogDeleteList fddl = new FragmentDialogDeleteList();
		
		Bundle args = new Bundle();
		args.putInt("position", position);
		args.putInt("num", num);
		fddl.setArguments(args);
		
		return fddl;
	}
		
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		String confirm = getResources().getString(R.string.class_fragmentdialog_confirm);
		String cancel = getResources().getString(R.string.class_fragmentdialog_cancel);
		String dialogtitle = getResources().getString(R.string.class_fragmentdialog_deletelist_dialogtitle);
		String dialogmessage = getResources().getString(R.string.class_fragmentdialog_deletelist_dialogmessage);
		
		
		layoutinflater = getActivity().getLayoutInflater();
		View view = layoutinflater.inflate(R.layout.fragment_dialog_deletelist,null);	
		dialog = new AlertDialog.Builder(getActivity()).setTitle(dialogtitle).setMessage(dialogmessage).setView(view);
			
		Bundle args = getArguments();
		if(args != null){
			position = args.getInt("position");
			num = args.getInt("num");
		}
		
		dialog.setPositiveButton(confirm, new OnClickListener() {		
			@Override
			public void onClick(DialogInterface dialog, int which) {
				switch(num){
				case 1:
					((DBListAcitiviryStep1)getActivity()).DeleteListPositiveDialog(num, position);
					break;
				case 2:
					((DBListAcitiviryStep2)getActivity()).DeleteListPositiveDialog(num, position);
					break;
				case 3:
					((DBListAcitiviryStep2)getActivity()).DeleteListPositiveDialog(num, position);	
					break;
				case 4:
					((DBListAcitiviryStep4)getActivity()).DeleteListPositiveDialog(num, position);	
					break;
				case 6:
					((DBListAcitiviryStep6)getActivity()).DeleteListPositiveDialog(num, position);	
					break;
				case 7:
					((MainTime)getActivity()).DeleteListPositiveDialog(num, position);
					break;
				case 9:
					((MainTime)getActivity()).DeleteListPositiveDialog(num, position);
					break;
					
				}
				
						
			}
		});	
		dialog.setNegativeButton(cancel, null);
		
		return dialog.create();
	}
	
}
